Skip to content

Conversation

Yiyiyimu
Copy link
Contributor

@Yiyiyimu Yiyiyimu commented Jun 21, 2021

Signed-off-by: yiyiyimu wosoyoung@gmail.com

  1. add option retry in health-check. When it is enabled, operations would keep trying the same endpoint till unhealthy, and then other endpoints, until success or no endpoints healthy. So we could ensure each operation would send to etcd with best effort.
    Currently not support for read_watch since it would be better to close the original connection and create a new watch with a new endpoint.
  2. move choose_enpoint into request_uri and request_chunk so it could find alternative endpoint easier

Signed-off-by: yiyiyimu <wosoyoung@gmail.com>
@Yiyiyimu Yiyiyimu force-pushed the feat/health-check-retry branch from a6c14c2 to 3daee06 Compare June 21, 2021 23:15
@Yiyiyimu Yiyiyimu changed the title feat: support retry in health-check for non-watch operation feat: support retry in health-check Jun 21, 2021
@Yiyiyimu
Copy link
Contributor Author

cc @tzssangglass @spacewander

Signed-off-by: yiyiyimu <wosoyoung@gmail.com>
end

self.init_count = (self.init_count or 0) + 1
local pos = self.init_count % endpoints_len + 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it intended to skip the first endpoint? As the minimal init_count here is 1.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also failed to figure out the purpose of this. It's the implementation of the earliest v3 API.
Hi @nic-chen do you remember why is it set so

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about self.init_count = (self.init_count or -1) + 1 ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also don’t remember, it’s contributed by the community

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. Fixed as suggested. Thanks!

elseif body.error and body.error.http_code >= 500 then
if health_check.conf ~= nil then
-- health_check retry should do nothing here
-- and let connection broke to create a new one
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

broke => broker?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I mean closed 🤣 fixed

return _request_uri(self, endpoint, "GET",
endpoint.http_host .. "/v2/stats/self",
nil, self.timeout)
return _request_uri(self, "GET", "/v2/stats/self", nil, self.timeout)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not about this PR: is there /v2 API in the /v3 file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not for API exists in both version, like /get and /put

Yiyiyimu added 4 commits June 21, 2021 23:43
Signed-off-by: yiyiyimu <wosoyoung@gmail.com>
Signed-off-by: yiyiyimu <wosoyoung@gmail.com>
Signed-off-by: yiyiyimu <wosoyoung@gmail.com>
Signed-off-by: yiyiyimu <wosoyoung@gmail.com>
@spacewander spacewander merged commit f84f5ae into api7:master Jun 22, 2021
Yiyiyimu referenced this pull request in Yiyiyimu/incubator-apisix Jun 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants